PROGRAM ON APPLET.
import java.applet.*;
import java.awt.*;
public class Sample extends Applet
{
String s;
public void init()
{
setBackground(Color.red);
setForeground(Color.green);
s=" This Is init Section";
}
public void start()
{
s=s+" This is Start Method";
}
public void paint(Graphics g)
{
g.drawString(s,20,30);
}
}
/*<applet code=Sample width=300 height=100>
</applet>*/
PROGRAM ON MOVING APPLET BANNER.
import java.applet.*;
import java.awt.*;
public class Sample1 extends Applet implements Runnable
{
boolean stopFlag;
Thread t;
String s=" V I S I O N C O M P U T E R S ";
public void init()
{
setBackground(Color.red);
setForeground(Color.blue);
}
public void start()
{
t=new Thread(this);
stopFlag=false;
t.start();
}
public void run()
{
char ch;
for(;;)
{
try
{
repaint();
Thread.sleep(250);
ch=s.charAt(0);
s=s.substring(1,s.length());
s=s+ch;
if(stopFlag)
break;
}
catch(InterruptedException e)
{
}
}
}
public void stop()
{
stopFlag=true;
t=null;
}
public void paint(Graphics g)
{
g.drawString(s,20,30);
showStatus("Main Road,Vuyyuru");
}
}
/*<applet code="sample1" width=300 height=50>
</applet>*/
WRITE A PROGRAM ON PARAMETERS.
import java.applet.*;
import java.awt.*;
public class Sample3 extends Applet
{
String fontname;
int fontsize;
float leading;
boolean active;
public void start()
{
String param;
fontname=getParameter("fontname");
if(fontname==null)
fontname="Not found";
param=getParameter("fontsize");
try
{
if(param!=null)
fontsize=Integer.parseInt(param);
else
fontsize=0;
}
catch(NumberFormatException e)
{
System.out.println(e);
}
param=getParameter("leading");
try
{
if(param!=null)
leading=Float.valueOf(param).floatValue();
else
leading=0;
}
catch(NumberFormatException e)
{
leading=-1;
}
param=getParameter("accountEnabled");
if(param!=null)
active=Boolean.valueOf(param).booleanValue();
}
public void paint(Graphics g)
{
g.drawString("font: "+fontname,0,10);
g.drawString("size: "+fontsize,0,26);
g.drawString("lead: "+leading,0,40);
g.drawString("Access: "+active,0,56);
}
}
/*<applet code=Sample3 width=100 height=200>
<param name=fontname value=courier>
<param name=fontsize value=12>
<param name=leading value=0>
<param name=accountEnabled value=true>
</applet>*/
import java.applet.*;
import java.awt.*;
import java.net.*;
public class Sample4 extends Applet
{
String m;
public void init()
{
setBackground(Color.yellow);
setForeground(Color.red);
}
public void paint(Graphics g)
{
URL u=getCodeBase();
m="Code Base"+u.toString();
g.drawString(m,20,30);
u=getDocumentBase();
m="DocumentBase"+u.toString();
g.drawString(m,10,40);
}
}
/*<applet code=Sample4 width=300 height=100>
</applet>*/